package com.test;

import com.modai.ClientMain;
import com.modai.proxy.RemoteApiProxy;
import com.modai.remote.api.UserAPI;
import com.modai.remote.dto.CommonResponse;
import com.modai.remote.entity.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Collections;

/**
 * @author ：modai
 * @date ：Created in 2021-6-6 13:48
 * @description：测试访问远程API
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ClientMain.class)
public class RemoteAPI {

    @Autowired
    private UserAPI userAPI;
//    private final UserAPI userAPI= RemoteApiProxy.getApi(UserAPI.class);

    @Test
    public void getUserNum(){
        CommonResponse<Integer> userNum = userAPI.getUserNum();
        System.out.println(userNum);
    }

    @Test
    public void getUser(){
        CommonResponse<User> user = userAPI.getUser(1);
        System.out.println(user.getResult());
    }
    @Test
    public void insertUser(){
        User user = new User("xiaohaha", "asdffasd", Collections.emptyList());
        CommonResponse<String> stringCommonResponse = userAPI.insertUser(user);
        System.out.println(stringCommonResponse.getResult());
    }

    @Test
    public void deleteUser(){
        CommonResponse<String> stringCommonResponse = userAPI.deleteUser(4);
        System.out.println(stringCommonResponse.getResult());
    }

    public static void main(String[] args) {
        final String[] a = new String[2];
        a[0] = "a";
        a[0]+="?";
        a[0]+="12312";
        System.out.println(a[0]);
    }
}
